00001 // Emacs Mode Line: -*- Mode:c++;-*- 00002 // ------------------------------------------------------------- 00003 /* 00004 * Copyright (c) 2013 Battelle Memorial Institute 00005 * Licensed under modified BSD License. A copy of this license can be found 00006 * in the LICENSE file in the top level directory of this distribution. 00007 */ 00008 // ------------------------------------------------------------- 00009 // ------------------------------------------------------------- 00010 /** 00011 * @file linear_matrix_solver.hpp 00012 * @author William A. Perkins 00013 <<<<<<< variant A 00014 * @date 2015-03-20 06:19:09 d3g096 00015 >>>>>>> variant B 00016 * @date 2015-02-13 08:29:11 d3g096 00017 ======= end 00018 * 00019 * @brief Declaration of the LinearMatrixSolver class 00020 * 00021 * 00022 */ 00023 // ------------------------------------------------------------- 00024 00025 00026 #ifndef _linear_matrix_solver_hpp_ 00027 #define _linear_matrix_solver_hpp_ 00028 00029 #include <boost/scoped_ptr.hpp> 00030 #include "gridpack/math/linear_matrix_solver_implementation.hpp" 00031 00032 namespace gridpack { 00033 namespace math { 00034 00035 // ------------------------------------------------------------- 00036 // class LinearMatrixSolver 00037 // ------------------------------------------------------------- 00038 /// A solver for multiple systems of linear equations 00039 /** 00040 * This class implements a linear solver that solves systems with one 00041 * coefficient matrix and many right hand sides. 00042 * 00043 * If the underlying math libray has a special facility for solving 00044 * multiple RHS, this class uses that. Otherwise, solve() is just an 00045 * interface to LinearSolver::solve(const Matrix& B). 00046 * 00047 * 00048 */ 00049 template <typename T, typename I = int> 00050 class LinearMatrixSolverT 00051 : public BaseLinearMatrixSolverInterface<T, I>, 00052 public parallel::WrappedDistributed, 00053 public utility::WrappedConfigurable, 00054 private utility::Uncopyable 00055 { 00056 public: 00057 00058 typedef typename BaseLinearMatrixSolverInterface<T, I>::MatrixType MatrixType; 00059 00060 /// Default constructor. 00061 LinearMatrixSolverT(MatrixType& A); 00062 00063 /// Destructor 00064 ~LinearMatrixSolverT(void) 00065 {} 00066 00067 protected: 00068 00069 /// Where the work is actually done 00070 boost::scoped_ptr< LinearMatrixSolverImplementation<T, I> > p_impl; 00071 00072 00073 /// Solve multiple systems w/ the specified RHS Matrix (specialized) 00074 /** 00075 * Each column in @c B represent a single right hand side. Each 00076 * column in the returned Matrix contains the solution corresponding 00077 * to the same column in @c B. @c B must be \ref Matrix::Dense 00078 * "dense" and the returned Matrix will be \ref Matrix::Dense 00079 * "dense". 00080 * 00081 * @param B RHS matrix 00082 * 00083 * @return (dense) solution Matrix 00084 */ 00085 MatrixType *p_solve(const MatrixType& B) const 00086 { 00087 return p_impl->solve(B); 00088 } 00089 00090 }; 00091 00092 typedef LinearMatrixSolverT<ComplexType> ComplexLinearMatrixSolver; 00093 typedef LinearMatrixSolverT<RealType> RealLinearMatrixSolver; 00094 typedef ComplexLinearMatrixSolver LinearMatrixSolver; 00095 00096 } // namespace math 00097 } // namespace gridpack 00098 00099 00100 #endif